import java.util.Scanner;

public class One {
    public static void main(String[] args) {
        int[][] a = new int[510][510];
        int[][] f = new int[510][510];
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i + 1; j++) {
                f[i][j] = Integer.MIN_VALUE;
            }
        }
        f[1][1] = a[1][1];
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                f[i][j] = Math.max(f[i - 1][j - 1], f[i - 1][j]) + a[i][j];
                // 一定要注意，先取MAX，再求和
            }
        }
        int res = Integer.MIN_VALUE;
        for (int k = 1; k <= n; k++) {
            res = Math.max(res, f[n][k]);
        }
        System.out.println(res);
    }

}